package codec;

import org.apache.mina.core.buffer.IoBuffer;
import org.apache.mina.core.session.IoSession;
import org.apache.mina.filter.codec.ProtocolEncoder;
import org.apache.mina.filter.codec.ProtocolEncoderOutput;

/**
 * Created by ryan on 15-8-25.
 */
public class FileRequestEncoder implements ProtocolEncoder {

    public void encode(IoSession session, Object message, ProtocolEncoderOutput out) throws Exception {
        FileRequest fr = (FileRequest) message;
        IoBuffer buffer = IoBuffer.allocate(8, false);
        buffer.putLong(fr.getStartPos());
        buffer.flip();
        out.write(buffer);
    }

    public void dispose(IoSession session) throws Exception {

    }
}
